Skip to content

deps: Replace vergen with a new support crate#2905

Merged
smalis-msft merged 4 commits intomicrosoft:mainfrom
smalis-msft:novergen
Mar 9, 2026
Merged

deps: Replace vergen with a new support crate#2905
smalis-msft merged 4 commits intomicrosoft:mainfrom
smalis-msft:novergen

Conversation

@smalis-msft
Copy link
Contributor

The vergen crate, and especially its new version 9, pulls in a lot of dependencies for the relatively small pieces of it we use. Replace it with a new home-grown crate that has no dependencies beyond anyhow and just does what we need.

@smalis-msft smalis-msft requested a review from a team as a code owner March 6, 2026 21:38
Copilot AI review requested due to automatic review settings March 6, 2026 21:38
@smalis-msft smalis-msft requested a review from a team as a code owner March 6, 2026 21:38
@github-actions
Copy link

github-actions bot commented Mar 6, 2026

⚠️ Unsafe Code Detected

This PR modifies files containing unsafe Rust code. Extra scrutiny is required during review.

For more on why we check whole files, instead of just diffs, check out the Rustonomicon

@github-actions github-actions bot added the unsafe Related to unsafe code label Mar 6, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the vergen dependency and replaces it with a small in-repo build-script helper crate that emits git SHA/branch information via cargo:rustc-env, reducing transitive dependency footprint while preserving build metadata.

Changes:

  • Add new support/build_rs_git_info crate to emit BUILD_GIT_SHA / BUILD_GIT_BRANCH using the git CLI.
  • Update OpenHCL crates’ build.rs and runtime code to use the new env var names instead of VERGEN_*.
  • Remove vergen from workspace dependencies and lockfile.

Reviewed changes

Copilot reviewed 12 out of 13 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
support/build_rs_git_info/src/lib.rs New helper implementation for invoking git and emitting build env vars.
support/build_rs_git_info/Cargo.toml Defines the new support crate and its minimal dependencies.
openhcl/underhill_init/src/lib.rs Switch runtime logging to BUILD_GIT_SHA / BUILD_GIT_BRANCH.
openhcl/underhill_init/build.rs Use build_rs_git_info instead of vergen.
openhcl/underhill_init/Cargo.toml Replace vergen build-dependency with build_rs_git_info.
openhcl/underhill_crash/src/lib.rs Switch crash metadata to BUILD_GIT_SHA.
openhcl/underhill_crash/build.rs Use build_rs_git_info instead of vergen.
openhcl/underhill_crash/Cargo.toml Replace vergen build-dependency with build_rs_git_info.
openhcl/build_info/src/lib.rs Switch BuildInfo fields to read BUILD_GIT_SHA / BUILD_GIT_BRANCH.
openhcl/build_info/build.rs Use build_rs_git_info instead of vergen.
openhcl/build_info/Cargo.toml Replace vergen build-dependency with build_rs_git_info.
Cargo.toml Add build_rs_git_info workspace dep; remove vergen version.
Cargo.lock Lockfile updates reflecting dependency removal/addition.

You can also share your feedback on Copilot code review. Take the survey.

@github-actions
Copy link

github-actions bot commented Mar 6, 2026

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.


You can also share your feedback on Copilot code review. Take the survey.

@smalis-msft smalis-msft enabled auto-merge (squash) March 9, 2026 17:36
@mattkur mattkur requested a review from Copilot March 9, 2026 19:07
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 13 changed files in this pull request and generated 1 comment.

let ref_path = git_path(&["rev-parse", "--git-path", &head_ref])?;
println!("cargo:rerun-if-changed={}", ref_path.display());
}

Copy link

Copilot AI Mar 9, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cargo:rerun-if-changed only watches HEAD and (if symbolic) the loose ref file (e.g. .git/refs/heads/main). If refs are packed (common after git gc / git pack-refs), that ref file may not exist and updates like git commit --amend won’t trigger a rebuild, leaving BUILD_GIT_SHA stale. Consider also watching packed-refs (via git rev-parse --git-path packed-refs) unconditionally, or otherwise ensuring ref updates are tracked even when refs are packed.

Suggested change
// Also watch the packed-refs file so ref updates are tracked even when
// branch refs are packed and the loose ref files no longer exist.
let packed_refs_path = git_path(&["rev-parse", "--git-path", "packed-refs"])?;
println!("cargo:rerun-if-changed={}", packed_refs_path.display());

Copilot uses AI. Check for mistakes.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I chatted with @smalis-msft offline. He experimented, and found that this is incorrect. This code will trigger a rebuild if that file doesn't exist.

@smalis-msft smalis-msft merged commit e506124 into microsoft:main Mar 9, 2026
64 checks passed
@smalis-msft smalis-msft deleted the novergen branch March 9, 2026 19:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

unsafe Related to unsafe code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants